How to detect touches on a gamepad by script using Java
In your Java class, do the following:
public class YourClass extends Component {
@Override
public void start() {
}
@Override
public void repeat() {
// checking if the touch of the joystick button "A" has been pressed and is different from null
if (Input.gamePad.getButton("A") != null && Input.gamePad.getButton("A").isDown()) {
// showing a message in the terminal if the conditional is true
Console.log("Button A detected!");
}
}
}